package com.dzt.cloudreader.utils;


import com.dzt.cloudreader.model.HotMovieBean.SubjectsBean.DirectorsBean;
import com.dzt.cloudreader.model.HotMovieBean.SubjectsBean.CastsBean;
import com.dzt.cloudreader.model.PersonBean;

import java.util.List;

/**
 * Created by jingbin on 2016/11/26.
 */

public class JStringFormatKit {

	/**
	 * 格式化导演、主演名字
	 */
	public static String formatName(List<CastsBean> casts) {
		if (casts != null && casts.size() > 0) {
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < casts.size(); i++) {
				if (i < casts.size() - 1) {
					stringBuilder.append(casts.get(i).getName()).append(" / ");
				} else {
					stringBuilder.append(casts.get(i).getName());
				}
			}
			return stringBuilder.toString();

		} else {
			return "佚名";
		}
	}

	public static String formatDirectors(List<DirectorsBean> casts){
		if (casts != null && casts.size() > 0) {
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < casts.size(); i++) {
				if (i < casts.size() - 1) {
					stringBuilder.append(casts.get(i).getName()).append(" / ");
				} else {
					stringBuilder.append(casts.get(i).getName());
				}
			}
			return stringBuilder.toString();

		} else {
			return "佚名";
		}
	}

	public static String formatPerson(List<PersonBean> casts){
		if (casts != null && casts.size() > 0) {
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < casts.size(); i++) {
				if (i < casts.size() - 1) {
					stringBuilder.append(casts.get(i).getName()).append(" / ");
				} else {
					stringBuilder.append(casts.get(i).getName());
				}
			}
			return stringBuilder.toString();

		} else {
			return "佚名";
		}
	}

	/**
	 * 格式化电影类型
	 */
	public static String formatGenres(List<String> genres) {
		if (genres != null && genres.size() > 0) {
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < genres.size(); i++) {
				if (i < genres.size() - 1) {
					stringBuilder.append(genres.get(i)).append(" / ");
				} else {
					stringBuilder.append(genres.get(i));
				}
			}
			return stringBuilder.toString();

		} else {
			return "不知名类型";
		}
	}
}
